/* UVa- 10189
 * Author- Ajeet Singh
 * http://uva.onlinejudge.org
 * id- ajeet.singh82
 * Contact- ajeet.singh82@gmail.com
 *
 * 
 * Algorithm: 
 *
 *
 * Build:
 * ...
 */
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
ostringstream oss;
void algorithm(string& prev, string& curr, string& res) {
	short m = curr.size();
	string next(m, '0');
	size_t pos = 0;
	while(pos < m) {
		if(curr[pos] == '*') {
			if(pos == 0) {
				curr[pos+1] != '*' ? curr[pos+1]=1 + res[pos+1]     : 0;
				prev[pos]   != '*' ? prev[pos]++                    : 0;
				prev[pos+1] != '*' ? prev[pos+1]++                  : 0;
				next[pos]++;
				next[pos+1]++;
			} else if(pos == curr.size()-1) {
				curr[pos-1] != '*' ? curr[pos-1]++					: 0;
				prev[pos]   != '*' ? prev[pos]++                    : 0;
				prev[pos-1] != '*' ? prev[pos-1]++                  : 0;
				next[pos]++;
				next[pos-1]++;
			} else {
				curr[pos+1] != '*' ? curr[pos+1]=1  + res[pos+1]    : 0;
				curr[pos-1] != '*' ? curr[pos-1]++					: 0;
				prev[pos]   != '*' ? prev[pos]++                    : 0;
				prev[pos+1] != '*' ? prev[pos+1]++                  : 0;
				prev[pos-1] != '*' ? prev[pos-1]++                  : 0;
				next[pos]++;
				next[pos+1]++;
				next[pos-1]++;
			}
		} else if(curr[pos] == '.'){
			curr[pos] = res[pos];
		} else {
		}
		pos++;
	}
	res = next;
}

/* main
 * */

int main() {
	long fields = 0;
	string curr;
	string prev;
	string res;
	curr.reserve(120);
	prev.reserve(120);
	res.reserve(120);
	while ( true ) {
		unsigned long n =0;
		unsigned long m =0;
		cin >> n >> m;
		if (n == 0 && m == 0) { 
			cout << oss.str();
			return 0;
		}
		prev= string().append(m, '0');
		res = string().append(m, '0');
		if(fields != 0) 
			oss << endl;
		fields++;
		oss << "Field #" << fields <<":" << endl;
		for (short i = 0; i < n; i++) {
			cin >> curr;
			algorithm(prev, curr, res);
			if(i > 0)
				oss << prev << endl;
			prev = curr;
		}
		oss << prev << endl;
	}
}
